package com.evan.uyclub.Other;

import android.app.Dialog;
import android.content.Context;

import androidx.annotation.NonNull;

import com.evan.uyclub.R;
import com.github.ybq.android.spinkit.SpinKitView;
import com.github.ybq.android.spinkit.sprite.Sprite;
import com.github.ybq.android.spinkit.style.CubeGrid;
import com.github.ybq.android.spinkit.style.FadingCircle;
import com.github.ybq.android.spinkit.style.Wave;
import com.sdsmdg.tastytoast.TastyToast;

import java.util.ArrayList;
import java.util.List;

public class VPNActivity extends Dialog {

    List<String> networkList;

    /**
     * 加载框工具
     *
     * @param context
     */
    public VPNActivity(@NonNull Context context) {
        super(context, R.style.dialogs);
        setContentView(R.layout.avtivity_vpn);
        SpinKitView spink = (SpinKitView) findViewById(R.id.spink);
        Sprite spinks = new CubeGrid();
        spink.setIndeterminateDrawable(spinks);
        //判断vpn
        networkList = new ArrayList<>();
        try {
            for (java.net.NetworkInterface networkInterface : java.util.Collections.list(java.net.NetworkInterface.getNetworkInterfaces())) {
                if (networkInterface.isUp()) {
                    networkList.add(networkInterface.getName());
                }
            }
        } catch (Exception ex) {
        }
        if (networkList.contains("tun0")) {
            setCancelable(false); // 返回键是否允许关闭
            setCanceledOnTouchOutside(false); // 点击界面是否允许关闭
            super.show();
        }

    }
}
